from app.configs.default import Config
import datetime
from datetime import timedelta


class DevConfig(Config):
    DEBUG = True
    SQLALCHEMY_ECHO = False

    REDIS_HOST = '10.8.0.3'
    REDIS_PORT = 16379
    REDIS_DBID = 0
    REDIS_PASSWORD = 'ironBackRedis123'

    SQLALCHEMY_CG_URI = 'mysql+pymysql://root:BICI123456@10.8.0.3:3306/cg'
    SQLALCHEMY_MYSQL_ONLINE_DATABASE_URI = 'mysql+pymysql://root:Cisco#123@10.8.0.3:13306/ironman_prod'

    MYSQL_HOST = "10.8.0.3"
    MYSQL_PORT = 3306
    MYSQL_USER = "root"
    MYSQL_PASSWORD = "BICI123456"
    MYSQL_DATABASE = "cg"

    IRONMAN_MYSQL_HOST = "10.8.0.3"
    IRONMAN_MYSQL_PORT = 13306
    IRONMAN_MYSQL_USER = "root"
    IRONMAN_MYSQL_PASSWORD = "Cisco#123"
    IRONMAN_MYSQL_DATABASE = "ironman_prod"

    KAFKA_SERVERS = ['192.168.40.214:9092', '192.168.40.214:9093', '192.168.40.214:9094']

    SQLALCHEMY_BINDS = {
        'serve_engine': SQLALCHEMY_MYSQL_ONLINE_DATABASE_URI,
        'cg': SQLALCHEMY_CG_URI
    }


    ENABLE_KAFKA = False

    # APScheduler 配置

    # 控制所有定时任务的开启
    SCHEDULE_SWITCH = True
    # SCHEDULER_API_ENABLED = True
    GAOLU_BANBIE_BACKTRACKING_ENABLED = False        # 高炉打分数据回溯定时
    HANFAN_DUMP_DATA_ENABLED = True  # 含钒原燃料数据查询定时

    # simulation 还需要设置 deamon.py 里面的具体时间节点
    SHAOJIE_SIMULATION_ENABLED = False
    GAOLU_SIMULATION_ENABLED = False
    HANFAN_SIMULATION_ENABLED = False

    INFLUXDB_HOST = '10.8.0.3'
    INFLUXDB_PORT = 8086
    INFLUXDB_USERNAME = 'admin'
    INFLUXDB_PASSWORD = 'BICI123456'
    INFLUXDB_DATABASE = 'bfbd2023'

    # 秒级别
    if GAOLU_SIMULATION_ENABLED:
        GAOLU_INTERVAL = 5
    else:
        GAOLU_INTERVAL = 3600  # 1 小时

    if SHAOJIE_SIMULATION_ENABLED:
        SHAOJIE_INTERVAL = 5
    else:
        SHAOJIE_INTERVAL = 5

    # 秒级别
    if HANFAN_SIMULATION_ENABLED:
        HANFAN_INTERVAL = 5
    else:
        HANFAN_INTERVAL = 3600  # 1 小时

    HANFAN_DUMP_DATA_INTERVAL = 1800    # 30分钟

    # cron表达式
    GAOLU_BANBIE_SCORE_BACKTRACKING = "0,8,16"

    JOBS = []

    # if SHAOJIE_SIMULATION_ENABLED:
    #     JOBS.append(
    #         {
    #             'id': 'shaojie_data_stream_simulate',
    #             'func': 'app.services.schedule.deamon:shaojie_demo_data_stream',
    #             'args': (),
    #             'trigger': 'interval',
    #             'seconds': SHAOJIE_INTERVAL
    #         }
    #     )
    #
    #     JOBS.append({
    #         'id': 'shaojie_model_predict_online',
    #         'func': 'app.services.schedule.deamon:shaojie_model_predict_online',
    #         'trigger': 'interval',
    #         'seconds': SHAOJIE_INTERVAL
    #     })
    #     JOBS.append(
    #         {
    #             'id': 'gaolu_model_predict',
    #             'func': 'app.services.schedule.deamon:gaolu_model_predict_online',
    #             'trigger': 'interval',
    #             'seconds': GAOLU_INTERVAL,
    #             'next_run_time': datetime.datetime.now() + datetime.timedelta(seconds=10)  # job在2分钟后立即运行
    #
    #         })
    #     JOBS.append(
    #         {
    #             'id': 'hanfan_model_predict',
    #             'func': 'app.services.schedule.deamon:hanfan_model_predict_online',
    #             'trigger': 'interval',
    #             'seconds': HANFAN_INTERVAL,
    #             'next_run_time': datetime.datetime.now() + datetime.timedelta(seconds=120)  # job在2分钟后立即运行
    #         })
    #
    # if GAOLU_SIMULATION_ENABLED:
    #     JOBS.append(
    #         {
    #             'id': 'gaolu_data_stream_simulate',
    #             'func': 'app.services.schedule.deamon:gaolu_demo_data_stream',
    #             'args': (),
    #             'trigger': 'interval',
    #             'seconds': GAOLU_INTERVAL
    #         }
    #     )
    #
    # if GAOLU_BANBIE_BACKTRACKING_ENABLED:
    #     JOBS.append(
    #         {
    #             'id': 'gaolu_banbie_backtracking_data',
    #             'func': 'app.services.schedule.deamon:gaolu_banbie_backtracking_data',
    #             'args': (),
    #             'trigger': 'cron',
    #             'hour': GAOLU_BANBIE_SCORE_BACKTRACKING
    #         }
    #     )
    #
    # if HANFAN_DUMP_DATA_ENABLED:
    #     JOBS.append(
    #         {
    #             'id': 'dump_hanfan_data',
    #             'func': 'app.services.schedule.deamon:dump_hanfan_data',
    #             'trigger': 'interval',
    #             'seconds': HANFAN_DUMP_DATA_INTERVAL,
    #             'next_run_time': datetime.datetime.now() + datetime.timedelta(minutes=10)  # job在10分钟后立即运行
    #         }
    #     )
    #
    # JOBS.append(
    #     {
    #         'id': 'dump_lugang_data',
    #         'func': 'app.services.schedule.deamon:dump_lugang_data',
    #         'trigger': 'interval',
    #         'seconds': 600,
    #         'args': (),
    #         # 'next_run_time': datetime.datetime.now()  # job在10分钟后立即运行
    #     }
    # )
    #
    # JOBS.append(
    #     {
    #         'id': 'dump_lugang_qinshi_data',
    #         'func': 'app.services.schedule.deamon:dump_lugang_qinshi_data',
    #         'trigger': 'interval',
    #         'seconds': 30,
    #         'args': (),
    #         'next_run_time': datetime.datetime.now()+timedelta(seconds=10)  # job在10分钟后立即运行
    #     }
    # )
    #
    # JOBS.append(
    #     {
    #         'id': 'dump_lugang_qinshi_model_data',
    #         'func': 'app.services.schedule.deamon:dump_lugang_qinshi_model_data',
    #         'trigger': 'interval',
    #         'seconds': 500,
    #         'args': (),
    #         # 'next_run_time': datetime.datetime.now()  # job在10分钟后立即运行
    #     }
    # )
    #
    # JOBS.append(
    #     {
    #         'id': 'cal_lugang_data_dist',
    #         'func': 'app.services.schedule.deamon:cal_lugang_data_dist',
    #         'trigger': 'interval',
    #         'seconds': 60,
    #         'args': (),
    #         # 'next_run_time': datetime.datetime.now()  # job在10分钟后立即运行
    #     }
    # )
    #
    # JOBS.append(
    #     {
    #         'id': 'dump_lugang_activeness_long',
    #         'func': 'app.services.schedule.deamon:dump_lugang_activeness_long',
    #         'trigger': 'interval',
    #         'seconds': 600,
    #         'args': (),
    #         # 'next_run_time': datetime.datetime.now()  # job在10分钟后立即运行
    #     }
    # )
    #
    # JOBS.append(
    #     {
    #         'id': 'dump_lugang_activeness_predict_long',
    #         'func': 'app.services.schedule.deamon:dump_lugang_activeness_predict_long',
    #         'trigger': 'interval',
    #         'seconds': 600,
    #         'args': (),
    #         # 'next_run_time': datetime.datetime.now()  # job在10分钟后立即运行
    #     }
    # )
    #
    # JOBS.append(
    #     {
    #         'id': 'dump_lugang_activeness_short',
    #         'func': 'app.services.schedule.deamon:dump_lugang_activeness_short',
    #         'trigger': 'interval',
    #         'seconds': 600,
    #         'args': (),
    #         # 'next_run_time': datetime.datetime.now()  # job在10分钟后立即运行
    #     }
    # )
    #
    # JOBS.append(
    #     {
    #         'id': 'dump_lugang_activeness_predict_short',
    #         'func': 'app.services.schedule.deamon:dump_lugang_activeness_predict_short',
    #         'trigger': 'interval',
    #         'seconds': 600,
    #         'args': (),
    #         # 'next_run_time': datetime.datetime.now()  # job在10分钟后立即运行
    #     }
    # )

    JOBS.append(
        {
            'id': 'cal_gaolu_diagnose',
            'func': 'app.services.schedule.deamon:cal_gaolu_diagnose',
            'trigger': 'interval',
            'seconds': 60,
            'args': (),
            'next_run_time': datetime.datetime.now()+timedelta(seconds=10)  # job在10分钟后立即运行
        }
    )
